package com.xoa.service.task.impl;


import com.xoa.dao.task.TaskManageMapper;
import com.xoa.dao.task.TaskRemindsMapper;
import com.xoa.dao.task.TaskTypeMapper;
import com.xoa.model.task.TaskManage;
import com.xoa.model.task.TaskReminds;
import com.xoa.model.task.TaskType;
import com.xoa.model.users.Users;
import com.xoa.service.task.TaskRemindsService;
import com.xoa.service.task.TaskTypeService;
import com.xoa.util.CookiesUtil;
import com.xoa.util.ToJson;
import com.xoa.util.common.StringUtils;
import com.xoa.util.common.session.SessionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;


@Service
public class TaskRemindsServiceImpl implements TaskRemindsService {
    @Resource
    private TaskRemindsMapper taskRemindsMapper;

    @Override
    public ToJson addTaskReminds(HttpServletRequest request,TaskReminds taskReminds) {
        ToJson toJson = new ToJson();
        try{
            List<TaskReminds> taskRemindslist =taskRemindsMapper.queryTaskReminds(taskReminds.getTaskId());
            if(taskRemindslist.size()>0){
                taskRemindsMapper.deleteTaskReminds(taskRemindslist.get(0).getId());

            }
            taskRemindsMapper.addTaskReminds(taskReminds);
            toJson.setFlag(0);
            toJson.setMsg("success");
        }catch (Exception e){
            toJson.setFlag(1);
            toJson.setMsg("erro");
            e.printStackTrace();
        }
        return toJson;
    }
}
